import gettext
from template.singleton import Singleton

class International(Singleton):
    def __init__(self,app_name, path_local) -> None:
        self.app_name = app_name
        self.path_local = path_local
        self.obj_gettext = None
        self.setting()

    def set_params(self, app_name, path_local):
        self.app_name = app_name
        self.path_local = path_local

    def setting(self):
        gettext.bindtextdomain(self.app_name, self.path_local)
        gettext.textdomain(self.app_name)
        self.obj_gettext = gettext.gettext
        if self.obj_gettext == None:
            raise Exception("Gettext error obj None")

    def get(self, text) -> str:
        return self.obj_gettext(text)

